﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

using Plugin;
using StandardFramework;

namespace StandardLibrary
{
    [ClassAttribute("System Bound", "Plugin.Media.brick.ico")]
    public class BoundComponentData : BaseComponent
    {
        public delegate void ChangeHandler(object sender, EventArgs args);

        [EventAttribute("Change", "Plugin.Media.lightning.ico")]
        public event ChangeHandler Change = null;

        protected void OnChange()
        {
            if (Change != null)
            {
                Change(this, null);
            }
        }

        private Rectangle _bound;

        public Rectangle Bound 
        {
            get { return _bound; }
        }

        public int X
        {
            get { return _bound.X; }
            set { _bound.X = value; OnChange(); }
        }

        public int Y
        {
            get { return _bound.Y; }
            set { _bound.Y = value; OnChange(); }
        }

        public int Width
        {
            get { return _bound.Width; }
            set { _bound.Width = value; OnChange(); }
        }

        public int Height
        {
            get { return _bound.Height; }
            set { _bound.Height = value; OnChange(); }
        }

        public BoundComponentData(Rectangle bound)
        {
            _bound = bound;
        }

        public void Move(int x, int y)
        {
            _bound.X += x;
            _bound.Y += y;
            OnChange();
        }

    }
}
